<template>
  <div>
    <el-form label-suffix="：" label-position="right" label-width="120px" size="mini">
      <el-row>
        <el-col span="8" v-for="(item, key) in studentBaseInfo" :key="key">
          <el-form-item :label="item.label">{{ item.value }}</el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
  export default {
    name: 'studentBaseInfo',
    data() {
      return {
        template: [
          {
            label: '姓名',
            key: 'studentName',
            value: ''
          },
          {
            label: '学号',
            key: 'studentId',
            value: ''
          },
          {
            label: '毕业年份',
            key: 'completionYear',
            value: ''
          },
          {
            label: '学院',
            key: 'collegeI18n',
            value: ''
          },
          {
            label: '专业',
            key: 'majorI18n',
            value: ''
          },
          {
            label: '学制',
            key: 'schoolingLength',
            value: ''
          },
          {
            label: '绩点',
            key: 'scorePoint',
            value: ''
          },
          {
            label: '总学分',
            key: 'totalCredit',
            value: ''
          },
          {
            label: '机审结果',
            key: 'status',
            value: ''
          }
        ],
        studentBaseInfo: [],
        statusMap: {
          "1" : "未结业",
          "2" : "已结业",
          "3" : "退回生源地",
        }
      }
    },
    methods: {
      init(studentBaseInfo = {}) {
        const result = [];
        this.template.forEach(item => {
          const clone = { ...item };
          clone.value = studentBaseInfo[clone.key];
          if (clone.key === 'totalCredit') {
            clone.value = `${studentBaseInfo['gotTotalCredit']}/${studentBaseInfo['totalCredits']}`;
          } else if (clone.key === 'status'){
            clone.value = this.statusMap[(clone.value || 1).toString()];
          }
          result.push(clone);
        });
        this.studentBaseInfo = result;
      }
    }
  }
</script>
